package cn.jhc;

import java.io.IOException;
 
//import java.util.Scanner;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
 
 
@WebServlet("/upload.do")
@MultipartConfig(location="/Users/info/Desktop/Sign", maxRequestSize=10485760)
public class UploadServlet extends HttpServlet { 
	private static final long serialVersionUID = 1L;
       
 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
		String rootPath = request.getServletContext().getRealPath("/");
		System.out.println(rootPath);
		
		/*Part filePart = request.getPart("file"); 
		String filename = filePart.getSubmittedFileName(); 
		int idx = filename.lastIndexOf('.'); 
		String ext = filename.substring(idx); 
		filePart.write(System.currentTimeMillis() + ext);*/
		
//		filePart.write(System.currentTimeMillis() + ".png"); 
//		在控制台输出用户注册的用户名
//		Part usernamePart = request.getPart("username"); 
//		String username = new Scanner(usernamePart.getInputStream()).next(); 
//		System.out.println(username); 
	}
 
}